#!/usr/bin/env python3

from bs4 import BeautifulSoup
import sys

soup = BeautifulSoup(open(sys.argv[1]).read(), "lxml")
trs = soup.find_all("tr",attrs={"class":"odd"})
trss = soup.find_all("tr", attrs={"class":""})

with open ("IP.txt", "a") as f:
    for tr in trs:
        ip = tr.find_all("td")[1].string
        port =tr.find_all("td")[2].string
        f.write("%s:%s\n" % (ip, port))
        print(ip, port)



with open("IP.txt", "a") as d:
    for trsa in trss[1:]:
        ip2 = trsa.find_all("td")[1].string
        port2 = trsa.find_all("td")[2].string
        d.write("%s:%s\n" % (ip2, port2))
        print(ip2, port2)
